package cn.onein.edu.web.util;

import java.io.IOException;
import java.io.Writer;

import javax.servlet.http.HttpServletResponse;

import org.mortbay.util.ajax.JSON;
import org.mortbay.util.ajax.JSON.Convertor;
import org.mortbay.util.ajax.JSONObjectConvertor;

import cn.onein.edu.web.vo.AjaxCallbackVO;

public class AjaxCallBackJsonUtil {

	public static void callbackJSON(AjaxCallbackVO vo,HttpServletResponse resp) throws IOException {
		Convertor convertor = new JSONObjectConvertor();
		JSON.registerConvertor(AjaxCallbackVO.class, convertor);
		resp.setContentType("text/json; charset=utf-8");
		Writer w = resp.getWriter();
		w.write(JSON.toString(vo));
		//System.out.println(JSON.toString(vo));
		w.close();
	}

}
